try:
    # 可能会发生各种各样的运行时错误
    f = open('test.txt')
    data = json.load(f)
finally:
    try:
        if 'f' in locals():
            f.close()
    except NameError:
        pass